package com.zkingsoft.actions.admin.pc;

import java.util.List;

import javax.annotation.Resource;

import com.zkingsoft.services.bus.BusParameterSettingsService;
import com.zkingsoft.services.pc.PcMealSettingsService;
import com.zkingsoft.pojo.PaginationVO;
import com.zkingsoft.model.bus.BusParameterSettings;
import com.zkingsoft.model.pc.PcMealSettings;
import com.zkingsoft.authority.MatrixAdapter;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.util.WebUtil;
import com.zkingsoft.constraint.BaseController;
import com.zkingsoft.pojo.AjaxResult;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zkingsoft.anotations.RemoveRequestToken;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2017-03-23 14:19
 */
@Controller
@RequestMapping(value = "admin/pcMealSettings")
public class PcMealSettingsController extends BaseController{
	Logger log = Logger.getLogger(this.getClass());
	@Resource
	private PcMealSettingsService pcMealSettingsService;
	
	@Resource
	private MatrixAdapter matrixAdapter;
	
	@Resource
	private BusParameterSettingsService busParameterSettingsService;
	
	//记录编辑前的值Before_Edit_Value
	public static final String BEV="PcMealSettings_BEV";
	public static final String fnCode = "PcMealSettings";
	public static final String search = fnCode + ":search";
	public static final String edit = fnCode + ":edit";
	public static final String del = fnCode + ":del";
	public static final String add = fnCode + ":add";
	
	/**
	 * 新增或者修改页面
	 */   
	//@RemoveRequestToken	
   	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(PcMealSettings pcMealSettings) {
			matrixAdapter.isBtnPermitted(add);
			return add(pcMealSettingsService, pcMealSettings, "配餐设置");
	}
	
   	/**
	 * 进入修改界面
	 */   
	//@SaveRequestToken
   	@RequestMapping(value = "/editForm")
	public String editForm() {
		matrixAdapter.isBtnPermitted(edit);
		List<PcMealSettings> mesList;
		mesList = pcMealSettingsService.findByModel(null);
		WebUtil.getRequest().setAttribute("mesList",  mesList);
		BusParameterSettings busParameterSettings=new BusParameterSettings();
		busParameterSettings.setParamCode("rs");
		 List<BusParameterSettings> busList=busParameterSettingsService.findByModel(busParameterSettings);
		 for(BusParameterSettings bus:busList){
			WebUtil.getRequest().setAttribute("bus", bus);
		}
		WebUtil.getRequest().setAttribute("mesList",  mesList);
		return "admin/pc/PcMealSettings-forWord";
	}
	
}